package com.xjy.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.xjy.common.utils.PageUtils;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import org.springframework.stereotype.Service;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.system.domain.bo.ReportCreditAdvanceQueryBo;
import com.xjy.system.domain.ReportCreditAdvance;
import com.xjy.system.mapper.ReportCreditAdvanceMapper;
import com.xjy.system.domain.vo.ReportCreditAdvanceVo;
import com.xjy.system.service.IReportCreditAdvanceService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 预付款情况Service业务层处理
 *
 * @author mlb
 * @date 2022-03-08
 */
@Service
public class ReportCreditAdvanceServiceImpl extends ServicePlusImpl<ReportCreditAdvanceMapper, ReportCreditAdvance> implements IReportCreditAdvanceService {

    @Override
    public ReportCreditAdvanceVo queryById(Long projId){
        return getVoById(projId, ReportCreditAdvanceVo.class);
    }

    @Override
    public TableDataInfo<ReportCreditAdvanceVo> queryPageList(ReportCreditAdvanceQueryBo bo) {
        PagePlus<ReportCreditAdvance, ReportCreditAdvanceVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportCreditAdvanceVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportCreditAdvanceVo> queryList(ReportCreditAdvanceQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportCreditAdvanceVo.class);
    }

    private LambdaQueryWrapper<ReportCreditAdvance> buildQueryWrapper(ReportCreditAdvanceQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportCreditAdvance> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getProjId() != null, ReportCreditAdvance::getProjId, bo.getProjId());
        lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportCreditAdvance::getProjName, bo.getProjName());
        lqw.eq(bo.getAdvanceColId() != null, ReportCreditAdvance::getAdvanceColId, bo.getAdvanceColId());
        lqw.like(StrUtil.isNotBlank(bo.getAdvanceColer()), ReportCreditAdvance::getAdvanceColer, bo.getAdvanceColer());
        return lqw;
    }

}
